<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
      
<head th:include="head :: htmlhead" th:with="title='协议生成管理'">
</head>
  
<body>
<form class="layui-form" action="" lay-filter="example">
  <div class="layui-form-item layui-inline" style="margin-top: 10px;">
    <label class="layui-form-label">版本号</label>
    <div class="layui-input-block">
      <input type="text" name="version" lay-verify="title" autocomplete="off" placeholder="版本号" class="layui-input">
    </div>
    
    <div class="layui-form-item" style="margin-top:  20px;">
        <div class="layui-input-block">
            <button  id="submit" class="layui-btn"  lay-submit lay-filter="addVersion">立即提交</button>
        </div>
    </div>
  </div>
</form>

<script>
    layui.use('form', function(){
        var form = layui.form;
        form.on('submit(addVersion)', function (data) {
            var version = data.field.version;
            $.ajax({
                type: 'POST',
                url: '/zproto/setting/addVersionSave?version='+version,
                dataType: 'json',
                contentType: "application/json; charset=utf-8",
                success: function(data){
                    var str = data.tips;
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    layer.confirm(str, {
                        btn: ['ok'] //按钮
                    }, function () {
                        parent.layer.close(index); //再执行关闭
                        parent.window.location.reload();
                    });
                },
                error: function(jqXHR){console.log(jqXHR)},
            });
            return false;
    });});
</script>

</body>
</html>
